#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N = 2e5 + 10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//
int n;
int main()
{
	close();
	cin >> n;
	ll m = 0;
	for (int i = 0; i < n; i++)
	{
		ll x;
		cin >> x;
		m += x;
	}

	int ans = 0;
	while (m != 0)
	{
		ans++;
		ll cur = 1;
		while (cur*2 <= m)
		{
			cur *= 2;
		}
		m -= cur;
	}

	if (m == 1) ans++;

	cout << ans << '\n';
	return 0;
}
